package sanbing.jcpplearning;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class ByteBufAttributesExample {
    public static void main(String[] args) {
        // 创建一个容量为 10 的 ByteBuf
        ByteBuf buffer = Unpooled.buffer(10);

        // 写入数据
        buffer.writeBytes(new byte[]{1, 2, 3, 4, 5});
        System.out.println("writerIndex: " + buffer.writerIndex()); // 输出 5
        System.out.println("readableBytes: " + buffer.readableBytes()); // 输出 5

        // 读取数据
        System.out.println("Read byte: " + buffer.readByte()); // 输出 1
        System.out.println("readerIndex: " + buffer.readerIndex()); // 输出 1
        System.out.println("readableBytes: " + buffer.readableBytes()); // 输出 4
    }
}